package com.agent.user.feign;

import cn.hutool.core.bean.BeanUtil;
import com.agent.common.result.ApiResponse;
import com.agent.user.api.feign.AdminUserFeignClient;
import com.agent.user.api.resp.AdminUserResp;
import com.agent.user.entity.AdminUser;
import com.agent.user.mapper.AdminUserMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Jeff_Wan
 * @description
 * @date 2025-08-08 16:45
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class AdminUserFeignClientImpl implements AdminUserFeignClient {

    private final AdminUserMapper adminUserMapper;

    @Override
    public ApiResponse<AdminUserResp> getUserByUsername(String username) {
        AdminUser adminUser = adminUserMapper.findByUsername(username);
        return ApiResponse.success(BeanUtil.copyProperties(adminUser, AdminUserResp.class));
    }
}
